package cn.bdqn.sys.controller;

import cn.bdqn.model.PageBean;
import cn.bdqn.sys.model.Enterprise;
import cn.bdqn.sys.service.EnterpriseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Awacky
 * @create 2019-07-28 11:58
 */
@Controller
@RequestMapping("/sys/enterprise")
public class EnterpriseController {

    @Autowired
    private EnterpriseService enterpriseService;

    @RequiresPermissions("sys:enterprise:page")
    @GetMapping
    public String page(){
        return "/sys/enterprise";
    }

    @RequiresPermissions("sys:enterprise:list")
    @ResponseBody
    @GetMapping("list")
    public Object list(PageBean pageBean, String name){
        return enterpriseService.list(pageBean,name);
    }

    @RequiresPermissions("sys:enterprise:add")
    @ResponseBody
    @PostMapping("add")
    public Object add(Enterprise enterprise){
        return enterpriseService.add(enterprise);
    }

    @RequiresPermissions("sys:enterprise:delete")
    @PostMapping("/delete")
    @ResponseBody
    public Object delete(Integer eid){
        return enterpriseService.delete(eid);
    }
}
